#!/usr/bin/env bash

set -e
# Timeout after 2 min if we still haven't gotten a response
timeout 120s bash <<EOT
# Wait until an HTTP request succeeds against localhost:PORT
function ping_server(){
    while true; do
        if curl -sSf "http://localhost:4000" >/dev/null; then
            exit 0
        fi
    done
}

ping_server
EOT
